<?php
//
//  VictoryCMS - Content managment system and framework.
//  Copyright (C) 2009  Lewis Gunsch
//
//  This file is part of VictoryCMS.
//  
//  VictoryCMS is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  VictoryCMS is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//  
//  You should have received a copy of the GNU General Public License
//  along with VictoryCMS.  If not, see <http://www.gnu.org/licenses/>.

/**
 * VictoryCMS - VcmsDBFactory
 * 
 * @license http://www.gnu.org/licenses/gpl.html
 * @author Lewis Gunsch
 * @filesource
 * @package DBAbstraction
 */

/**
 * Creates instances of VcmsDb to use for interfacing with a database.
 *   
 * @package DBAbstraction
 * 
 */
class VcmsDBFactory {
	
	/**
	 * Creates a new VcmsDb class depending on 
	 * the type of database selected in the configuration
	 * file loaded by Settings.php
	 * 
	 * @todo this should throw a cutom exception
	 * 
	 * @return VcmsDB A new VcmsDB child.
	 */
	public static function createVcmsDb() {
		
		$settings = VcmsSettings::getInstance();
		switch( $settings->getDbType() ) {
			case "mysql": return new VcmsMySQL(); break;
			case "pgsql": return new VcmsPgSQL(); break;
			//TODO: throw custom exception here
			default : die("Did not recognize database type!");
		}
	}
}
?>